package net.chathu.airgw.packets.chat 
{
	import net.chathu.airgw.model.PrivateChatInfo;
	import net.chathu.airgw.util.ByteArrayUtil;
	/**
	 * ...
	 * @author ze
	 */
	public class SubPrivate extends ChatPacket 
	{
		
		public function SubPrivate() 
		{
			
		}
		
		override public function execute():void
		{
			var pos:int=data[1].indexOf("/")+1;
			var privateId:int = parseInt(data[1].substring(pos));
			
			var privInfo:PrivateChatInfo = sessionData.chatData.getPrivateChatInfo(privateId);
			
			if (privInfo)
			{
				var messages:Vector.<String> = sessionData.chatData.privateMessageQueue.removePartnerMessages(privInfo.partnerId);
				for each(var message:String in messages)
				{
					trace("Message sent from queue: " + message);
					sendToChat(ByteArrayUtil.convertParams(["m","private/"+privInfo.privateId,message]));
				}
			} else {
				trace("Hianyzo privInfo, privateId: " + privateId);
			}
			trace("QUEUE size: " + sessionData.chatData.privateMessageQueue.totalMesssagesInQueue);
			
		}
		
	}

}